@(issue: gitbucket.core.model.Issue,
  pullreq: gitbucket.core.model.PullRequest,
  commits: Seq[gitbucket.core.util.JGitUtil.CommitInfo],
  comments: List[gitbucket.core.model.Comment],
  issueLabels: List[gitbucket.core.model.Label],
  collaborators: List[String],
  milestones: List[(gitbucket.core.model.Milestone, Int, Int)],
  priorities: List[gitbucket.core.model.Priority],
  labels: List[gitbucket.core.model.Label],
  isEditable: Boolean,
  isManageable: Boolean,
  isManageableForkedRepository: Boolean,
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  forkedRepository: Option[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
<div class="col-md-9">
  <div id="comment-list">
    @gitbucket.core.issues.html.commentlist(Some(issue), comments, isManageable, repository, Some(pullreq))
  </div>
  @defining(comments.flatMap {
    case comment: gitbucket.core.model.IssueComment => Some(comment)
    case other => None
  }.exists(_.action == "merge")){ merged =>
    @if(!issue.closed){
      <div class="check-conflict" style="display: none;">
        <div class="issue-comment-box" style="background-color: #fbeed5">
          <div class="box-content"class="issue-content" style="border: 1px solid #c09853; padding: 10px;">
            <img src="@helpers.assets("/common/images/indicator.gif")"/> Checking...
          </div>
        </div>
      </div>
    }
    @if(isManageableForkedRepository && issue.closed && merged &&
      forkedRepository.map(r => (r.branchList.contains(pullreq.requestBranch) && r.repository.defaultBranch != pullreq.requestBranch)).getOrElse(false)){
      <div class="issue-comment-box" style="background-color: #d0eeff;">
        <div class="box-content"class="issue-content" style="border: 1px solid #87a8c9; padding: 10px;">
          <a href="@helpers.url(repository)/pull/@issue.issueId/delete_branch" class="btn btn-info pull-right delete-branch" data-name="@pullreq.requestBranch">Delete branch</a>
          <div>
            <span class="strong">Pull request successfully merged and closed</span>
          </div>
          <span class="small muted">You're all set. The <span class="label label-info monospace">@pullreq.requestBranch</span> branch can now be safely deleted.</span>
        </div>
      </div>
    }
    @gitbucket.core.issues.html.commentform(issue, !merged, isEditable, isManageable, repository)
  }
</div>
<div class="col-md-3">
  @gitbucket.core.issues.html.issueinfo(Some(issue), comments, issueLabels, collaborators, milestones, priorities, None, labels, isManageable, repository)
</div>
<script>
$(function(){
  @if(commits.nonEmpty){
    var checkConflict = $('.check-conflict').show();
    if(checkConflict.length){
      $.get('@helpers.url(repository)/pull/@issue.issueId/mergeguide', function(data){ $('.check-conflict').html(data); });
    }
  }
  $('.delete-branch').click(function(e){
    var branchName = $(e.target).data('name');
    return confirm('Are you sure you want to remove the ' + branchName + ' branch?');
  });
});
</script>
